#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
简单API测试脚本
"""

import requests
import json

def test_url(url):
    """测试单个URL"""
    print(f"\n测试: {url}")
    try:
        response = requests.get(url, timeout=5)
        print(f"状态码: {response.status_code}")
        print(f"响应内容: {response.text[:300]}..." if len(response.text) > 300 else f"响应内容: {response.text}")
    except Exception as e:
        print(f"错误: {str(e)}")

# 测试健康检查端点
print("测试健康检查端点...")
test_url("http://127.0.0.1:5000/health")

# 测试根路径
print("\n测试根路径...")
test_url("http://127.0.0.1:5000/")

# 测试几个可能的API路径前缀
print("\n测试API路径前缀...")
for prefix in ["/api", "/v1", "/scanner", "/vulnerability"]:
    test_url(f"http://127.0.0.1:5000{prefix}")

print("\n测试完成！")